package algotithm.interview.民生科技test.test2;

import java.io.*;

/**
 * @author zhouyanxiang
 * @Date 2021-03-2021/3/6-19:59
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(reader.readLine());
        int[] a = new int[n];
        String[] arr = reader.readLine().split(" ");
        for (int i = 0;i < n; i++) {
            a[i] = Integer.parseInt(arr[i]);
        }
        int res = 0;
        for (int i = 1; i < n; i++) {
            if (a[i] < a[i-1]) {
                res++;
                swap(a,i,i-1);
            }
        }
        writer.write(res + "\n");
        writer.flush();
        writer.close();
        reader.close();
    }

    public static void swap(int[] arr, int i ,int j) {
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }

}
